package com.sumainfor.common.wechat;

import com.google.gson.Gson;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/3/20 19:12
 * @Description:
 */
public class MapUtil {

    public static Map<String,Object> str2Map(String data){
        Gson gson = new Gson();
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map = gson.fromJson(data, map.getClass());
        return map;
    }



    public static void cleanNull(Map map) {
        Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Object> entry = it.next();
            String key = entry.getKey();
            Object value = entry.getValue();
            if (null == value || value.equals("")) {
                it.remove();
            }
        }
    }
}
